<?php
$this->breadcrumbs = array(
	'材料列表',
);

$this->userActions = array(
	array(
		'label' => '新建材料',
		'url' => array(
			'create'
		),
		'visible' => Yii::app()->user->checkAccess('materialManage'),
		'iconClass' => 'icon-cog-add'
	),
);
Yii::app()->clientScript
	->registerScript('search-material',
		"
$('#material-search-button').click(function(){
        $.fn.yiiListView.update('material-list', {
                data: $('#material-search-form').serialize()
        });
        return false;
});
");
?>

<h1>材料列表</h1>
<div class="form">
<?php $form = $this
	->beginWidget('CActiveForm',
		array(
			'id' => 'material-search-form',
			'action' => Yii::app()->createUrl($this->route),
			'method' => 'get',
		));
?>
	<?php echo $form->errorSummary($searchModel); ?>
<fieldset>
<legend>搜索条件</legend>

	<div class="span-8">
		<?php echo $form->labelEx($searchModel, 'categoryId'); ?>
		<?php echo $form
			->dropDownList($searchModel, 'categoryId',
				CHtml::listData(MaterialCategory::getAll(), 'id', 'name'),
				array(
					'empty' => ''
				));
		?>
	</div>
	<div class="span-8">
		<?php echo $form->labelEx($searchModel, 'name'); ?>
		<?php echo $form
			->textField($searchModel, 'name',
				array(
					'size' => 10,
					'maxlength' => 255
				));
		?>
		<?php echo $form->error($searchModel, 'name'); ?>
	</div>
	<div class="clear"></div>
<!-- 
	<div class="span-8">
		<?php //echo $form->labelEx($searchModel, 'tagId'); ?>
		<?php //echo $form->textField($searchModel, 'tagId', array(
			//	'size' => 20
			//));
		?>
	</div>
	<div class="clear"></div>
 -->
	<div class="row buttons">
		<?php echo CHtml::submitButton('搜索', array(
			'id' => 'material-search-button'
		));
		?>
	</div>

</fieldset>
<?php $this->endWidget(); ?>
</div>
<?php $this
	->widget('zii.widgets.CListView',
		array(
			'id' => 'material-list',
			'dataProvider' => $dataProvider,
			'itemView' => '_view',
			'separator' => '<div class="list-item-separator"></div>',
		));
?>
